﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using QuanLyTiemVang.DTO;

namespace QuanLyTiemVang.DAO
{
    class BaoCaoDoanhThuDAO
    {
        private static QUANLYTIEMVANGEntities dbContext = new QUANLYTIEMVANGEntities();

        public static List<BAOCAODOANHTHU> SelectAllBaoCaoDoanhThu()
        {
            var query = from d in dbContext.BAOCAODOANHTHUs
                        select d;

            if (query.ToList().Count == 0)
                return null;

            return query.ToList();
        }
        public static void Insert(BAOCAODOANHTHU bcdt)
        {
            dbContext.BAOCAODOANHTHUs.Add(bcdt);
            dbContext.SaveChanges();
        }

        // news Quy
        public static BAOCAODOANHTHU SelectLast()
        {
            var query = from d in dbContext.BAOCAODOANHTHUs
                        select d;

            if (query.ToList().Count == 0)
                return null;

            return query.OrderByDescending(m => m.MaBaoCaoDoanhThu).FirstOrDefault();
        }
    }
}
